package com.bp.hearthealth.pulse.lnapps.ads.timer

/**
 * @author isnoam
 * @package_name TimerObservable
 * @description：
 */
class TimerObservable {

    private val timerObserverList = mutableListOf<TimerObserver>()
    fun registerObserver(timerObserver: TimerObserver) {
        if (!timerObserverList.contains(timerObserver)) {
            timerObserverList.add(timerObserver)
        }
    }

    fun unRegisterObserver(timerObserver: TimerObserver) {
        if (timerObserverList.contains(timerObserver)) {
            timerObserverList.remove(timerObserver)
        }
    }

    fun notifyObserver() {
        if (timerObserverList.isNotEmpty()) {
            timerObserverList.forEach { timerObserver ->
                timerObserver.clearCache()
            }
        }
    }
}